<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24"> </a-row>
      </a-form>
    </div>

    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <a slot="projectName" @click="toDetailPage(record)" slot-scope="text, record">{{ text }}</a>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">缴费</a>
          <a-divider type="vertical" />
          <a @click="downloadFile">下载保函</a>
        </span>
      </a-table>
    </div>

    <finan-bid-record-modal ref="modalForm" @ok="modalFormOk"></finan-bid-record-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import FinanBidRecordModal from './modules/FinanBidRecordModal'
import { downloadFile } from '@/api/manage'

export default {
  name: 'FinanBidRecordList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    FinanBidRecordModal,
  },
  data() {
    return {
      description: '投标人记录管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        // {
        //   title:'主键',
        //   align:"center",
        //   dataIndex: 'guid'
        // },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'projectName',
          key: 'projectName',
          slots: { title: 'projectName' },
          scopedSlots: { customRender: 'projectName' },
        },
        {
          title: '项目编号',
          align: 'center',
          dataIndex: 'projectCode',
        },
        // {
        //   title:'标段主键',
        //   align:"center",
        //   dataIndex: 'bidSectionGuid'
        // },
        {
          title: '标段名称',
          align: 'center',
          dataIndex: 'bidSectionName',
        },
        {
          title: '标段编号',
          align: 'center',
          dataIndex: 'bidSectionCode',
        },
        {
          title: '投标单位',
          align: 'center',
          dataIndex: 'bidUnit',
        },
        {
          title: '投标单位代码(主体代码)',
          align: 'center',
          dataIndex: 'bidUnitCode',
        },
        {
          title: '开标时间',
          align: 'center',
          dataIndex: 'openBidTime',
        },
        {
          title: '地区标识',
          align: 'center',
          dataIndex: 'cityId',
        },
        {
          title: '投标时间',
          align: 'center',
          dataIndex: 'tenderTime',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/finanBidRecord/list',
        delete: '/finanBidRecord/delete',
        deleteBatch: '/finanBidRecord/deleteBatch',
        exportXlsUrl: '/finanBidRecord/exportXls',
        importExcelUrl: '/finanBidRecord/importExcel',
        downloadurl: '/finanTenderInfo/download',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    toDetailPage(record) {
      this.$router.push({ path: '/profile/advanced' })
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'guid', text: '主键' })
      fieldList.push({ type: 'string', value: 'projectName', text: '项目名称' })
      fieldList.push({ type: 'string', value: 'projectCode', text: '项目编号' })
      fieldList.push({ type: 'string', value: 'bidSectionGuid', text: '标段主键' })
      fieldList.push({ type: 'string', value: 'bidSectionName', text: '标段名称' })
      fieldList.push({ type: 'string', value: 'bidSectionCode', text: '标段编号' })
      fieldList.push({ type: 'string', value: 'bidUnit', text: '投标单位' })
      fieldList.push({ type: 'string', value: 'bidUnitCode', text: '投标单位代码(主体代码)' })
      fieldList.push({ type: 'string', value: 'openBidTime', text: '开标时间' })
      fieldList.push({ type: 'string', value: 'cityId', text: '地区标识' })
      fieldList.push({ type: 'string', value: 'tenderTime', text: '投标时间' })
      this.superFieldList = fieldList
    },
    downloadFile() {
      downloadFile(this.url.downloadurl, '投标保函.docx', {})
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>